home *** CD-ROM | disk | FTP | other *** search
- #include "GrayDraw 3D.h"
-
-
- enum {
- kBackgroundGrayRGB = 52428,
- kDarkGrayRGB = 39321,
- kDarkestGrayRGB = 17476, //21845,
-
- kWhiteRGB = 65535,
- kBlackRGB = 0
- };
-
-
- // Needs to be fixed: may draw outside of bounding boxRect!
- void GrayDrawBox(short inset, const Rect *boxRect, const GrayDrawInfoPtr grayInfo) {
- RGBColor bgGray, darkGray, darkestGray;
- RGBColor white;
- RGBColor saveFore, saveBack;
-
- GetForeColor(&saveFore);
- GetBackColor(&saveBack);
-
- if (grayInfo != NULL) {
- bgGray = grayInfo->bgGray;
- darkGray = grayInfo->darkGray;
- darkestGray = grayInfo->darkestGray;
- }
- else {
- bgGray.red = bgGray.green = bgGray.blue = kBackgroundGrayRGB;
- darkGray.red = darkGray.green = darkGray.blue = kDarkGrayRGB;
- darkestGray.red = darkestGray.green = darkestGray.blue = kDarkestGrayRGB;
- }
-
- white.red = white.green = white.blue = kWhiteRGB;
-
- RGBForeColor(&bgGray);
- //PaintRect(boxRect);
-
- if (inset)
- RGBForeColor(&darkestGray);
- else
- RGBForeColor(&white);
- // Draw outer top line
- MoveTo(boxRect->left, boxRect->top);
- LineTo(boxRect->right, boxRect->top);
- // Draw outer left line
- MoveTo(boxRect->left, boxRect->top);
- LineTo(boxRect->left, boxRect->bottom);
-
- if (inset)
- RGBForeColor(&darkGray);
- else
- RGBForeColor(&white);
- // Draw inner top line
- MoveTo(boxRect->left+1, boxRect->top+1);
- LineTo(boxRect->right-1, boxRect->top+1);
- // Draw inner left line
- MoveTo(boxRect->left+1, boxRect->top+1);
- LineTo(boxRect->left+1, boxRect->bottom-1);
-
- if (inset)
- RGBForeColor(&white);
- else
- RGBForeColor(&darkestGray);
- // Draw outer right line
- MoveTo(boxRect->right, boxRect->top+1);
- LineTo(boxRect->right, boxRect->bottom);
- // Draw outer bottom line
- MoveTo(boxRect->left+1, boxRect->bottom);
- LineTo(boxRect->right, boxRect->bottom);
-
- if (inset)
- RGBForeColor(&white);
- else
- RGBForeColor(&darkGray);
- // Draw inner right line
- MoveTo(boxRect->right-1, boxRect->top+2);
- LineTo(boxRect->right-1, boxRect->bottom-1);
- // Draw inner bottom line
- MoveTo(boxRect->left+2, boxRect->bottom-1);
- LineTo(boxRect->right-2, boxRect->bottom-1);
-
- RGBForeColor(&saveFore);
- RGBBackColor(&saveBack);
- } // END GrayDrawBox
-
- // ---------------------------------------------------------------------------
-
- void GrayDrawShadowLine(const Rect *lineRect, const GrayDrawInfoPtr grayInfo) {
- RGBColor darkestGray;
- RGBColor white;
- RGBColor saveFore, saveBack;
- Rect shadowRect;
-
- GetForeColor(&saveFore);
- GetBackColor(&saveBack);
-
- if (grayInfo != NULL) {
- darkestGray = grayInfo->darkestGray;
- }
- else {
- darkestGray.red = darkestGray.green = darkestGray.blue = kDarkestGrayRGB;
- }
-
- white.red = white.green = white.blue = kWhiteRGB;
-
- RGBForeColor(&darkestGray);
- FrameRect(lineRect);
-
- shadowRect = *lineRect;
- if ((lineRect->right - lineRect->left) > (lineRect->bottom - lineRect->top))
- OffsetRect(&shadowRect, 0, 1);
- else
- OffsetRect(&shadowRect, 1, 0);
- RGBForeColor(&white);
- FrameRect(&shadowRect);
-
- RGBForeColor(&saveFore);
- RGBBackColor(&saveBack);
- } // END GrayDrawShadowLine
-
- // ---------------------------------------------------------------------------
-
- void GrayDrawShadowBox(const Rect *boxRect, const GrayDrawInfoPtr grayInfo) {
- Rect lineRect;
-
- // Left line
- lineRect = *boxRect;
- lineRect.right = lineRect.left + 1;
- GrayDrawShadowLine(&lineRect, grayInfo);
-
- // Top line
- lineRect = *boxRect;
- lineRect.bottom = lineRect.top + 1;
- lineRect.left++;
- GrayDrawShadowLine(&lineRect, grayInfo);
-
- // Right line
- lineRect = *boxRect;
- lineRect.left = lineRect.right - 1;
- OffsetRect(&lineRect, -1, 0);
- GrayDrawShadowLine(&lineRect, grayInfo);
-
- // Bottom line
- lineRect = *boxRect;
- lineRect.top = lineRect.bottom - 1;
- lineRect.right--;
- OffsetRect(&lineRect, 0, -1);
- GrayDrawShadowLine(&lineRect, grayInfo);
- } // END GrayDrawShadowBox